<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>事件的添加</title>
		<script>
			function addShijian(){
				document.getElementById("btn").onclick=function(){
					alert("点击了按钮");
				};
			}
			window.onload=addShijian;
		</script>
	</head>
	<body>
		<button type="button" id="btn">点击我</button>
		
	</body>
</html>